<template>
	<view class="big">
		 <textarea  placeholder="    请输入投诉详细说明" id="textarea" maxlength="100"/>
		<view class="imgheader">
			<image v-if="imgUrl" :src="imgUrl" class="show"></image>
			<!-- 这是上传图片的开始 -->
			 <view  class="upload" @click="getImgInfo()">
			 	<text class="icon">✚</text>
			 </view>
		</view>
		<button type="primary" ></button>
	</view>
</template>

<script>
		
		
	export default{
		
		
		
		
		data(){
			return{
				imgUrl:"",
				baseUrl:"https://slimmings.healthmach.com/api/plugs/uploads",
				BASEURL:'https://slimmings.healthmach.com'
			}
		},
		methods:{
			getImgInfo(){
				
				uni.chooseImage({
				    count: 6, //默认9
				    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				    sourceType: ['album'], //从相册选择
				    success:  (res)=> {
				        console.log(res.tempFilePaths[0]);
						// this.imgUrl=res.tempFilePaths[0];
						// 这是上传文件的开始
						
						 uni.uploadFile({
						url: this.baseUrl, //仅为示例，非真实的接口地址
						filePath: res.tempFilePaths[0],
						name: 'files',
						success: (uploadFileRes) => {
						
						const  OBJ=	JSON.parse(uploadFileRes.data)
						console.log(OBJ)
						this.imgUrl=this.BASEURL+OBJ.data
						 console.log( this.imgUrl,'我执行了')
							
						}
					});
						
						
				    }
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.upload{
		height: 200rpx;
		width: 200rpx;
		border: 1px solid #ccc;
		position: relative;
		.icon{
			position: absolute;
			 top: 50%;
			 left: 50%;
			 font-size: 20px;
			 transform: translate(-50%,-50%);
		}
	}
	#textarea{
	
		width: 100%;
		vertical-align: 20px;
		padding: 15px 0px 0px 10px ;
		box-sizing: border-box;
		
	}
	.imgheader{
		display: flex;
			.show{
				height: 200rpx;
				width: 200rpx;
			}
	}




.big{

  height: 100%;

  width: 100%;

}

	
	
	
	

	

</style>
